package Bubble;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;

import PathPoint.Path;

import com.golden.gamedev.Game;
import com.golden.gamedev.object.Sprite;

public class Bubble extends Sprite
{
	/*
	public double x;
    public double y;
    public double t;
    public double phase;
    public Sprite bm;
    public Bubble next;
    public Bubble prev;
    public boolean shot;
    // Detemine whether there is a fish inside the bubble
    public boolean fish_inside;
    public double attach_x;
    public double attach_y;
    public double trans;
    public int combo; // num of combos?
    
    public Bubble()
    {
    	
    }
    */
	
	private double myT;
	private double myPhase;
	private boolean myShot; //?
	private boolean myFishInside;
	private double myTrans;
	private int myCombo;
	private double path_t0;
	private double path_last_t;
	
	private final int RAD_BUBBLE = 13;
	
	public Bubble(BufferedImage image)
	{
		super(image);
		myFishInside = true;
		myShot = false;
		myCombo = 0;
	}
	
	public boolean isFishInside()
	{
		return myFishInside;
	}
	
	public void setFishInside(boolean inside)
	{
		myFishInside = inside;
	}
	
	public int getCombo()
	{
		return myCombo;
	}
	
	public void setCombo(int combo)
	{
		myCombo = combo;
	}
	
	public double getPhase()
	{
		return myPhase;
	}
	
	public void setPhase(double phase)
	{
		myPhase = phase;
	}
	
	public double getTrans()
	{
		return myTrans;
	}
	
	public void setTrans(double trans)
	{
		myTrans = trans;
	}
	
	public double getT()
	{
		return myT;
	}
	
	public void setT(double t)
	{
		myT = t;
	}
	
	public boolean getShot()
	{
		return myShot;
	}
	
	public void setShot(boolean shot)
	{
		myShot = shot;
	}
	
	/**
	 * Set parameters
	 * @param p1
	 * @param p2
	 */
	public void setP(double p1, double p2)
	{
		path_t0 = p1;
		path_last_t = p2;
	}
	
	@Override
	public void update(long elapsedTime)
	{
		double time = ((double) elapsedTime)/1000.0;
		updatePathBubble(path_t0, path_last_t, time);
		super.update(elapsedTime);
	}
	
	/**
	 * Update bubble property
	 * @param path_t0
	 * @param path_last_t
	 * @param elapsedTime
	 */
	public void updatePathBubble(double path_t0, 
			double path_last_t, 
			double elapsedTime)
	{
		if (path_t0 + getX() >= path_last_t)
		{
			//setActive(false);
			// TODO: set game over and clear myBubblePath
			return;
		}
		
		myPhase += (elapsedTime % 1.0);
		myTrans = Math.max(0, myTrans - 4 * elapsedTime);
		Bubbles.updateBubbleLocation(path_t0, this);
		
	}
	
}
